package interfacecode.useDemo;

import interfacecode.Output;

import java.io.OutputStream;

/**
 * @author:Gan Linghao
 * @date:2020/7/16 0016
 * @time:16:31
 * @description:no description
 */
public class Printer implements Product, Output {
    private String[] printData = new String[MAX_CACHE];

    /**
     * 记录当前需要打印的作业数
     */
    private int dataNum = 0;
    @Override
    public void out() {
        while (dataNum > 0 ){
            System.out.println("打印机打印：" + printData[0]);
            System.arraycopy(printData, 1, printData, 0, --dataNum);
        }
    }

    @Override
    public String out2() {
        return null;
    }

    @Override
    public void getData(String msg) {
        if (dataNum >= MAX_CACHE) {
            System.out.println("已满，不能再添加");
        }else {
            printData[dataNum++] = msg;
        }
    }

    @Override
    public int getProductTime() {
        System.out.println("我是实现类Printer里面的getProductTime()方法体");
        return 0;
    }

    public static void main(String[] args) {
        Output o = new Printer();
        o.getData("JAVA接口应用");
        o.getData("JAVA EE 应用");
        o.out();

        o.print("海贼王", "火影", "西游记");

        Product p = new Printer();
        p.getProductTime();
    }
}
